#include "StdAfx.h"
#include "cGround.h"
//------------------------------------------------------------------------------------------------------------------------
cGround::cGround( void )
{
	for ( int i = 0;  i<3; i++ )
	{
		Ground[i].mPosition = D3DXVECTOR3(0.f, 0.f, MAP_Z_SIZE*i );
		Ground[i].mScale		= D3DXVECTOR3(3.f, 3.f, 3.f);
		Ground[i].mRotation = D3DXVECTOR3(D3DX_PI/2, 0.f, 0.f);
	}
	
	//Euro X_file
	//mRotation = D3DXVECTOR3(0.f, 0.f, 0.f);
}
//------------------------------------------------------------------------------------------------------------------------
cGround::~cGround(void)
{
}
//------------------------------------------------------------------------------------------------------------------------
void cGround::Update( D3DXVECTOR3 getPlayerPosition )
{
	for ( int i = 0; i<3; i++ )
	{
		{
			if ( getPlayerPosition.x < PLAYER_X - 10.f && getPlayerPosition.x > PLAYER_X - 40.f && Ground[i].mPosition.x > -60.f )
			{
				Ground[i].mPosition.x -= 0.3f;
			}
			else
				Ground[i].mPosition.x +=0.3f;
		}
		{
			if ( getPlayerPosition.x > PLAYER_X + 10.f  &&  getPlayerPosition.x < PLAYER_X + 40.f && Ground[i].mPosition.x < +60.f )
			{
				Ground[i].mPosition.x += 0.3f;
			}
			else
				Ground[i].mPosition.x -= 0.3f;
		}
		if ( Ground[i].mPosition.z >= -MAP_Z_SIZE)
		{
			Ground[i].mPosition.z -= 1.1f;
		}
		else
			Ground[i].mPosition.z +=MAP_Z_SIZE*3; 
	}
}
//------------------------------------------------------------------------------------------------------------------------
void cGround::Create()
{
	cModelMgr& mgr = cModelMgr::getInstance();

	Ground[0].mModel = mgr.getModel("Ground_1");
	Ground[1].mModel = mgr.getModel("Ground_2");
	Ground[2].mModel = mgr.getModel("Ground_3");
}
//------------------------------------------------------------------------------------------------------------------------
void cGround::render( bool bDraw )
{
	for (int i = 0; i<3; i++)
	{
		Ground[i].render( bDraw, "nUse" );
	}
}
//------------------------------------------------------------------------------------------------------------------------

